package com.cloning;

public class Student implements Cloneable {
	int sid;
	String name;
	Address studAdd;
	LoginInfo login;
	public Student(int sid, String name, Address studAdd, LoginInfo login) {
		this.sid = sid;
		this.name = name;
		this.studAdd = studAdd;
		this.login = login;
	}
@Override
public String toString() {
	return "Stud Info:\t"+sid+"\t"+name+"\t"+"\n Add Info:\t"+studAdd+"\t"+"\n Login Info:\t"+login;
}
@Override
protected Object clone() throws CloneNotSupportedException {
Object obj = null;
if (this instanceof Cloneable){
	Address ad = new Address(this.studAdd.aid, this.studAdd.street);
	LoginInfo info =new LoginInfo(this.login.username, this.login.pwd);
	obj = new Student(this.sid, this.name, ad, info);
	}
else{
	throw new CloneNotSupportedException(this.getClass().getName());
}return obj;
}
}
